/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package aufgabe2;

import java.io.Serializable;
import java.security.Principal;
import java.util.*;

/**
 * User is a basic concept for acess management and superclass for all persons
 * who are intended to use the application. User can be an observer, principal
 * and serializeable.
 * 
 * @author Lukas Koell
 * @author David Medenjak
 * @author Johannes Riedmann
 */
public abstract class User implements Serializable, Principal, Observer {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    /** the notifications a user received **/
    protected ArrayList<String> notifications;

    /** name of the user */
    private String name;

    /**
     * simple constructor, nothing special here
     */
    public User() {
        notifications = new ArrayList<String>();
    }

    /**
     * getter for the name attribute
     */
    public String getName() {
        return name;
    }

    /**
     * @param name
     *            the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * this method should return a unique Id number - it must be unique for
     * every object that subclasses this class
     * 
     * @return the unique id
     */
    public abstract int getId();

    /**
     * getter for the notifications a user received
     * 
     * @return the notifications
     */
    public ArrayList<String> getNotifications() {
        return notifications;
    }

    /**
     * default implementation for Observer pattern override in subclass if you
     * only want to receive notifications of a certain type
     */
    public void update(Observable o, Object arg) {
        notifications.add(arg.toString());
    }

}
